package com.gs.SynAntiWandering;

import android.app.Application;
import android.content.Intent;
import android.text.TextUtils;

import com.gs.SynAntiWandering.activity.LoginActivity;
import com.gs.SynAntiWandering.util.AppUtil;
import com.gs.SynAntiWandering.util.CrashHandler;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        AppUtil.getInstance().initContext(getApplicationContext());
        String processName = AppUtil.getInstance().getProcessName();
        if (!TextUtils.isEmpty(processName) && processName.equals(getPackageName())) {
            // 捕获全局异常
            CrashHandler crashHandler = CrashHandler.getInstance();
            crashHandler.init();
        }
    }

    public static void startLogin() {
        Intent intent = new Intent(AppUtil.getInstance().getContext(), LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        AppUtil.getInstance().getContext().startActivity(intent);
    }
}
